
package sbc.corso;

import sbc.model.Sensor;
import corso.lang.*; 

public class ReadTestPlatine
{ 
  public static void main (String [] args) 
  { 
	
	String myid = "Platine";
	  
    try 
    { 

    	CorsoConnection myCorsoConnection = CorsoUtil.getCorsoConnection();
 

        if (myCorsoConnection.isConnected ()) 
        { 
          System.out.println ("Connection ok"); 
        } 
 
        // get the named object *********************************************** 
        CorsoVarOid namedOid = new CorsoVarOid (); 
        try 
        { 
          namedOid = myCorsoConnection.getNamedVarOid (myid, 
                                                CorsoUtil.SITE, 
                                                null, 
                                                false, 
                                                CorsoConnection.NO_TIMEOUT); 
        } 
        catch (CorsoException e1) 
        { 
          System.out.println ("Cannot get named oid " + e1); 
          System.exit (-1); 
        } 
        System.out.println ("getting named oid - ok"); 
 
        // create data structure and read data into it ************************ 
        SensorSharable testSensorSharable = new SensorSharable("","");
        PlatineSharable struct = new PlatineSharable ("", testSensorSharable, testSensorSharable, ""); 
        namedOid.readShareable (struct, 
                                null, 
                                CorsoConnection.NO_TIMEOUT); 
        System.out.println ("reading named oid - ok"); 
        System.out.println ("value = " + struct.myId); 
        System.out.println ("value = " + struct.myFirstSensor.myId); 
        System.out.println ("value = " + struct.mySecondSensor.myId); 
        System.out.println ("value = " + struct.Status); 
 
        // disconnect from CORSO ********************************************** 
        myCorsoConnection.disconnect (); 
       
    } 
    catch (Exception e) 
    { 
      System.out.println ("Exception: " + e); 
      e.printStackTrace (); 
      System.exit (-1); 
    } 
  } 
} 
 
